<template>
	<view>
		<uni-section title="增加面试" type="line"></uni-section>
		<view class="example">
			<uni-forms ref="baseForm" :modelValue="baseFormData">
				<uni-forms-item label="面试公司" required>
					<uni-easyinput v-model="baseFormData.companyname" placeholder="请输入公司名" />
				</uni-forms-item>
				<uni-forms-item label="面试岗位" required>
					<uni-easyinput v-model="baseFormData.job" placeholder="请输入面试的岗位" />
				</uni-forms-item>
				<uni-forms-item label="公司坐标" required>
					<uni-easyinput v-model="baseFormData.latlang" placeholder="请输入面试的坐标" />
				</uni-forms-item>
				<uni-forms-item label="hr 电话" required>
					<uni-easyinput v-model="baseFormData.phone" placeholder="请输入hr电话" />
				</uni-forms-item>
				<uni-forms-item label="招聘平台" required >
					<view class="uni-form-item uni-column">
						<picker @change="bindPickerChange" :range="array">
							<uni-easyinput v-model="array[baseFormData.plat]" />
						</picker>
					</view>
				</uni-forms-item>
				<uni-forms-item label="日期时间" style="z-index: 999;">
					<uni-datetime-picker type="time" return-type="datetime" v-model="baseFormData.timeview" />
				</uni-forms-item>
				<uni-forms-item label="面试要求">
					<uni-easyinput type="textarea" v-model="baseFormData.info" placeholder="请输入公司的硬性要求" />
				</uni-forms-item>
				<view style="text-align: center">
					<button type="primary" size="mini" style="background-color:#81d3f8" @click="submit('baseForm')">提交</button>
				</view>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				array: ['--请选择平台--', '拉勾网', "前程无忧", "boss直聘", '智联招聘'],
				baseFormData: {
					companyname: '',
					latlang: '',
					job: '',
					phone: '',
					plat: 0,
					timeview: '2021-08-08 10:00',
					info: ''
				}
			}
		},
		methods: {
			bindPickerChange(e) { //改变的事件名
				this.baseFormData.plat = e.target.value;
			},
			submit(ref) {
				this.$refs[ref].validate().then(res => {
					console.log(res)
					uni.request({
						header: {
							"Content-Type": "application/json"
						},
						url: 'http://39.106.207.209:8100/interview/addInterview',
						method: 'POST',
						data: res,
						success: (res) => {
							// console.log(res);
							this.$refs[ref].resetFields();
							uni.switchTab({
							    url: '/pages/list/list'
							});
						}
					});
				})

			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/uni-nvue.scss';

	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		margin-left: 10px;
	}
</style>
